using ASP;
using HoWave.Common;
using HoWave.Web;
using HoWave.Web.Admin;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Web.Profile;
using System.Web.SessionState;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
public class HL_Admin_Admin_ToCash : Admin, IRequiresSessionState
{
	protected DropDownList ddlTypename;
	protected TextBox txtSearchmcd;
	protected DropDownList ddlStetua;
	protected HtmlInputText TxtBeginDate;
	protected HtmlInputText TxtEndDate;
	protected TextBox TextBox3;
	protected TextBox TextBox4;
	protected Button SearchButton;
	protected Repeater Repeater1;
	protected HtmlTableRow noread;
	protected Label Label2;
	protected LinkButton btnFirst;
	protected LinkButton btnBack;
	protected LinkButton btnNext;
	protected LinkButton btnLast;
	protected Label lblPageCount;
	protected DropDownList ddlGo;
	private ToCashBLL _cash = null;
	private DataTable dt1 = null;
	protected DefaultProfile Profile
	{
		get
		{
			return (DefaultProfile)this.Context.Profile;
		}
	}
	protected global_asax ApplicationInstance
	{
		get
		{
			return (global_asax)this.Context.ApplicationInstance;
		}
	}
	protected ToCashBLL To_cash
	{
		get
		{
			ToCashBLL cash;
			if (this._cash == null)
			{
				this._cash = new ToCashBLL(this.conn);
				cash = this._cash;
			}
			else
			{
				cash = this._cash;
			}
			return cash;
		}
	}
	public int PageIndex
	{
		get
		{
			return (int)this.ViewState["PageIndex"];
		}
		set
		{
			this.ViewState["PageIndex"] = value;
		}
	}
	public int PageSize
	{
		get
		{
			return (int)this.ViewState["PageSize"];
		}
		set
		{
			this.ViewState["PageSize"] = value;
		}
	}
	public int PageCount
	{
		get
		{
			return (int)this.ViewState["PageCount"];
		}
		set
		{
			this.ViewState["PageCount"] = value;
		}
	}
	public int Stamp
	{
		get
		{
			return (int)this.ViewState["Stamp"];
		}
		set
		{
			this.ViewState["Stamp"] = value;
		}
	}
	public int ViewType
	{
		get
		{
			return (int)this.Session["View"];
		}
		set
		{
			this.Session["View"] = value;
		}
	}
	public int RecordCount
	{
		get;
		set;
	}
	protected void Page_Load(object sender, EventArgs e)
	{
		if (!base.IsPostBack)
		{
			this.PageIndex = 1;
			this.ViewState["PageSize"] = 15;
			this.Stamp = 1;
			this.dt1 = this.To_cash.GetToChaShTableD(this.PageIndex, this.PageSize);
			this.ShowData(this.PageIndex, this.dt1, this.Repeater1);
			IList list = new List<int>();
			for (int i = 1; i <= this.PageCount; i++)
			{
				list.Add(i);
			}
			this.ddlGo.DataSource = list;
			this.ddlGo.DataBind();
			this.TxtBeginDate.Attributes.Add("onclick", "SelectDate(" + this.TxtBeginDate.UniqueID + ",'yyyy-MM-dd');");
			this.TxtEndDate.Attributes.Add("onclick", "SelectDate(" + this.TxtEndDate.UniqueID + ",'yyyy-MM-dd');");
		}
	}
	public void ShowData(int pageIndex, DataTable dt, Repeater rpter)
	{
		if (this.Stamp == 1)
		{
			this.RecordCount = this.To_cash.GetToChashCount().Rows.Count;
		}
		else
		{
			this.RecordCount = this.To_cash.GetTochashBySearchCount(this.ddlGo.SelectedValue, this.txtSearchmcd.Text, this.ddlStetua.SelectedValue, this.TxtBeginDate.Value, this.TxtEndDate.Value, this.TextBox3.Text, this.TextBox4.Text).Rows.Count;
		}
		this.PageCount = ((this.RecordCount % this.PageSize == 0) ? (this.RecordCount / this.PageSize) : (this.RecordCount / this.PageSize + 1));
		if (this.PageIndex == 1)
		{
			this.btnFirst.Enabled = false;
			this.btnBack.Enabled = false;
			this.btnNext.Enabled = true;
			this.btnLast.Enabled = true;
		}
		else
		{
			if (this.PageIndex >= this.PageCount)
			{
				this.PageIndex = this.PageCount;
				this.btnFirst.Enabled = true;
				this.btnBack.Enabled = true;
				this.btnNext.Enabled = false;
				this.btnLast.Enabled = false;
			}
			else
			{
				this.btnFirst.Enabled = true;
				this.btnBack.Enabled = true;
				this.btnNext.Enabled = true;
				this.btnLast.Enabled = true;
			}
		}
		if (this.PageCount == 0 || this.RecordCount <= this.PageSize)
		{
			this.btnFirst.Enabled = false;
			this.btnBack.Enabled = false;
			this.btnNext.Enabled = false;
			this.btnLast.Enabled = false;
		}
		this.Label2.Text = "共" + this.RecordCount.ToString() + "条订单";
		this.lblPageCount.Text = string.Concat(new object[]
		{
			"页次:",
			this.PageIndex,
			"/",
			this.PageCount,
			"页 ",
			this.PageSize,
			" 位订单/页"
		});
		if (dt.Rows.Count != 0)
		{
			rpter.DataSource = dt;
			this.noread.Visible = false;
		}
		else
		{
			this.noread.Visible = true;
		}
		rpter.DataBind();
		foreach (RepeaterItem repeaterItem in this.Repeater1.Items)
		{
			HiddenField hiddenField = (HiddenField)repeaterItem.FindControl("HiddenField1");
			HtmlImage htmlImage = (HtmlImage)repeaterItem.FindControl("imgStute");
			HyperLink hyperLink = (HyperLink)repeaterItem.FindControl("HyperLink1");
			Label label = (Label)repeaterItem.FindControl("Label1");
			if (hiddenField.Value == "2")
			{
				htmlImage.Src = "Images/sucess.jpg";
				hyperLink.NavigateUrl = "";
				hyperLink.Text = "已审核";
			}
			else
			{
				if (hiddenField.Value == "1")
				{
					htmlImage.Src = "Images/error.jpg";
					hyperLink.NavigateUrl = "Admin_Audit.aspx?ID=" + label.Text;
					hyperLink.Text = "审核";
				}
				else
				{
					if (hiddenField.Value == "3")
					{
						htmlImage.Src = "Images/error.jpg";
						hyperLink.NavigateUrl = "";
						hyperLink.Text = "已关闭";
					}
				}
			}
		}
	}
	protected void btnFirst_Click(object sender, EventArgs e)
	{
		this.PageIndex = 1;
		if (this.Stamp == 1)
		{
			this.dt1 = this.To_cash.GetToChaShTableD(this.PageIndex, this.PageSize);
			this.ShowData(this.PageIndex, this.dt1, this.Repeater1);
		}
		else
		{
			if (this.Stamp == 2)
			{
				this.dt1 = this.To_cash.GetTochashBySearch(this.PageIndex, this.PageSize, this.ddlGo.SelectedValue, this.txtSearchmcd.Text, this.ddlStetua.SelectedValue, this.TxtBeginDate.Value, this.TxtEndDate.Value, this.TextBox3.Text, this.TextBox4.Text);
				this.ShowData(this.PageIndex, this.dt1, this.Repeater1);
			}
		}
	}
	protected void btnBack_Click(object sender, EventArgs e)
	{
		this.PageIndex--;
		if (this.Stamp == 1)
		{
			this.dt1 = this.To_cash.GetToChaShTableD(this.PageIndex, this.PageSize);
			this.ShowData(this.PageIndex, this.dt1, this.Repeater1);
		}
		else
		{
			if (this.Stamp == 2)
			{
				this.dt1 = this.To_cash.GetTochashBySearch(this.PageIndex, this.PageSize, this.ddlGo.SelectedValue, this.txtSearchmcd.Text, this.ddlStetua.SelectedValue, this.TxtBeginDate.Value, this.TxtEndDate.Value, this.TextBox3.Text, this.TextBox4.Text);
				this.ShowData(this.PageIndex, this.dt1, this.Repeater1);
			}
		}
	}
	protected void btnNext_Click(object sender, EventArgs e)
	{
		this.PageIndex++;
		if (this.Stamp == 1)
		{
			this.dt1 = this.To_cash.GetToChaShTableD(this.PageIndex, this.PageSize);
			this.ShowData(this.PageIndex, this.dt1, this.Repeater1);
		}
		else
		{
			if (this.Stamp == 2)
			{
				this.dt1 = this.To_cash.GetTochashBySearch(this.PageIndex, this.PageSize, this.ddlGo.SelectedValue, this.txtSearchmcd.Text, this.ddlStetua.SelectedValue, this.TxtBeginDate.Value, this.TxtEndDate.Value, this.TextBox3.Text, this.TextBox4.Text);
				this.ShowData(this.PageIndex, this.dt1, this.Repeater1);
			}
		}
	}
	protected void btnLast_Click(object sender, EventArgs e)
	{
		this.PageIndex = this.PageCount;
		if (this.Stamp == 1)
		{
			this.dt1 = this.To_cash.GetToChaShTableD(this.PageIndex, this.PageSize);
			this.ShowData(this.PageIndex, this.dt1, this.Repeater1);
		}
		else
		{
			if (this.Stamp == 2)
			{
				this.dt1 = this.To_cash.GetTochashBySearch(this.PageIndex, this.PageSize, this.ddlGo.SelectedValue, this.txtSearchmcd.Text, this.ddlStetua.SelectedValue, this.TxtBeginDate.Value, this.TxtEndDate.Value, this.TextBox3.Text, this.TextBox4.Text);
				this.ShowData(this.PageIndex, this.dt1, this.Repeater1);
			}
		}
	}
	protected void ddlGo_SelectedIndexChanged(object sender, EventArgs e)
	{
		this.PageIndex = Convert.ToInt32(this.ddlGo.SelectedValue);
		if (this.Stamp == 1)
		{
			this.dt1 = this.To_cash.GetToChaShTableD(this.PageIndex, this.PageSize);
			this.ShowData(this.PageIndex, this.dt1, this.Repeater1);
		}
		else
		{
			if (this.Stamp == 2)
			{
				this.dt1 = this.To_cash.GetTochashBySearch(this.PageIndex, this.PageSize, this.ddlGo.SelectedValue, this.txtSearchmcd.Text, this.ddlStetua.SelectedValue, this.TxtBeginDate.Value, this.TxtEndDate.Value, this.TextBox3.Text, this.TextBox4.Text);
				this.ShowData(this.PageIndex, this.dt1, this.Repeater1);
			}
		}
	}
	protected void SearchButton_Click(object sender, EventArgs e)
	{
		string value = this.TxtBeginDate.Value.Trim();
		string value2 = this.TxtEndDate.Value.Trim();
		if (!string.IsNullOrEmpty(value) && !string.IsNullOrEmpty(value2))
		{
			if (Convert.ToDateTime(value) > Convert.ToDateTime(value2))
			{
				this.WriteErrMsg("", Language.Get("Common/DateTimeErr"), "");
			}
		}
		string text = this.TextBox3.Text.Trim();
		string text2 = this.TextBox4.Text.Trim();
		if (!string.IsNullOrEmpty(text))
		{
			if (!Text.IsNumber(text))
			{
				this.WriteErrMsg("", "输入的第一个金额值不是数字！", "");
			}
		}
		if (!string.IsNullOrEmpty(text2))
		{
			if (!Text.IsNumber(text2))
			{
				this.WriteErrMsg("", "输入的第二个金额值不是数字！", "");
			}
			if (!string.IsNullOrEmpty(text))
			{
				if (Convert.ToDouble(text) > Convert.ToDouble(text2))
				{
					this.WriteErrMsg("", "第一个金额值不能大于第二个金额值！", "");
				}
			}
		}
		this.Stamp = 2;
		this.dt1 = this.To_cash.GetTochashBySearch(this.PageIndex, this.PageSize, this.ddlTypename.SelectedValue, this.txtSearchmcd.Text, this.ddlStetua.SelectedValue, this.TxtBeginDate.Value, this.TxtEndDate.Value, this.TextBox3.Text, this.TextBox4.Text);
		this.ShowData(this.PageIndex, this.dt1, this.Repeater1);
	}
}
